package class_1_8.interface_test;

class A implements Cloneable{
    int num;

    @Override
    protected A clone() throws CloneNotSupportedException {
        return (A)super.clone();
    }
}
public class B implements Cloneable{
    A a=new A();

    @Override
    protected B clone() throws CloneNotSupportedException {
        B newB=(B)super.clone();
        newB.a=a.clone();
        return newB;
//        return (B)super.clone();
    }

    public static void main(String[] args) throws CloneNotSupportedException {
        B b1=new B();
        B b2=b1.clone();
        System.out.println(b1==b2);
        System.out.println(b2.a.num);
        b1.a.num=100;
        System.out.println(b2.a.num);  //浅拷贝
    }
}
